import Vue from 'vue'
import Router from 'vue-router'
import Login from '@/components/Login'


Vue.use(Router)

export default new Router({
  mode: 'history', //HTML5 History 模式,不丑的URL,需要后端配置
  routes: [
    {
      path: '/admin/login',
      name: 'Login',
      component: resolve => require(['@/components/Login'], resolve),
    },{
      path: '/admin',
      name: 'Nav',
      redirect: { name: 'Home' },
      component: resolve => require(['@/components/Nav'], resolve),
      children: [{
                path: 'home', //相对路径，路径为/home
                name: 'Home',
                component: resolve => require(['@/components/Home'], resolve)
            },{
                  path:'home/:id',
                  name:'ArticlePostid',
                  component:resolve => require(['@/components/ArticlePostid'], resolve)
            },{
                  path:'home/modify/:id',
                  name:'Modify',
                  component:resolve => require(['@/components/Modify'], resolve)
                  //alias: '/home/modify/:id'
            },{
                path: 'add',
                name: 'Add',
                component: resolve => require(['@/components/Add'], resolve)
            },{
                path: 'drafts',
                name: 'Drafts',
                component: resolve => require(['@/components/Drafts'], resolve)
            },{
                path: 'drafts/:id',
                name: 'EditDraft',
                component: resolve => require(['@/components/EditDraft'], resolve)
            },{
                path: 'statistics',
                name: 'Statistics',
                component: resolve => require(['@/components/Statistics'], resolve)
            },{
                path: 'about',
                name: 'about',
                component: resolve => require(['@/components/About'], resolve)
            },{
                path:'404',
                name: '404',
                component: resolve => require(['@/components/404'], resolve)
            }]
    },{
      path:'*',
      redirect: { name: '404' }
    }
  ]
})
